<template>
  <div id="login-window">
    <p>个人网上银行</p>
    <span>卡号:</span><input type="text" v-model="account.cardno"><br>
    <span>密码:</span><input type="password" v-model="account.password"><br>
    <input type="button" value="登录网上银行" @click="login()">
  </div>
</template>

<script>
import instance from "../utils/request";

export default {
  name: "Login",
  data(){
    return {
      account:{}
    };
  },
  methods:{
    login(){
      instance.post('/account/login',this.account).then(res=>{
        let re = new RegExp("^[a-zA-Z0-9]+$");//匹配英文和数字
        if (re.test(res.data)){
          this.$router.push({//路由跳转并存值
            name:'Index',
            params:{
              cardno:res.data
            }
          });
        }else {
          alert(res.data);
        }
      });
    }
  }
}
</script>

<style scoped>
#login-window{
  height: 300px;
  width: 500px;
  background-color: #90EE90;
  margin: auto;
  margin-top: 100px;
}
#login-window p{
  font-size: 30px;
  font-weight: bold;
  text-align: center;
}
input{
  /*input上下间距*/
  margin-top: 5px;
}
</style>
